/*
 * main.cpp
 *
 *  Created on: 2008-7-6
 *      Author: zarra
 */

#include "scim-dbus-frontend.h"

using namespace scim;

//Module Interface
static Pointer<ScimSide> _scim_frontend(0);
static int _argc;
static char **_argv;

extern "C" {
void scim_module_init(void) {
	setlocale(LC_ALL, "zh_CN.UTF-8");
	SCIM_DEBUG_FRONTEND(1) << "Initializing Socket FrontEnd module...\n";
}

void scim_module_exit(void) {
	SCIM_DEBUG_FRONTEND(1) << "Exiting Socket FrontEnd module...\n";
	_scim_frontend.reset();
}

void scim_frontend_module_init(const BackEndPointer &backend,
		const ConfigPointer &config, int argc, char **argv) {
	if (_scim_frontend.null()) {
		SCIM_DEBUG_FRONTEND(1) << "Initializing Socket FrontEnd module (more)...\n";
		_scim_frontend = new ScimSide(backend);
		_argc = argc;
		_argv = argv;
	}
}

void scim_frontend_module_run(void) {
	if (!_scim_frontend.null()) {
		SCIM_DEBUG_FRONTEND(1) << "Starting Socket FrontEnd module...\n";
		_scim_frontend->init(_argc, _argv);
		_scim_frontend->run();
	}
}
}
